var playerDao = module.exports;

var logger = require('pomelo-logger').getLogger(__filename);
var pomelo = require('pomelo');
var utils  = require('../util/utils');



playerDao.getUserInfo = function (username, passwd, cb) {
	var sql = 'select * from player where name = ?';
	var args = [username];

	pomelo.app.get('dbclient').query(sql,args,function(err, res) {
		if(err !== null) {
				utils.invokeCallback(cb, err, null);
		} else {
			if (!!res && res.length === 1) {
				var rs = res[0];
				var userId = rs.id;
				rs.uid = rs.id;
				utils.invokeCallback(cb,null, rs);
			} else {
				utils.invokeCallback(cb, null, {uid:0, username: username});
			}
		}
	});
};